home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] Best way to "define" flag values?
- Date: 22 Jan 1996 20:43:01 GMT
- Organization: Computer People Inc.
- Distribution: na
- Message-ID: <ALUN.CHAMPION.96Jan22154301@g7240065.bridge.bst.bls.com>
- References: <marnoldDLIv9w.1s4@netcom.com> <cmanDLKAqG.Drt@netcom.com>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: cman@netcom.com's message of Mon, 22 Jan 1996 02:54:16 GMT
-
- In article <cmanDLKAqG.Drt@netcom.com> cman@netcom.com (Mike Austin) writes:
-
- : Here's a little essay that I did a while ago. I still think the same
- : way now, but my views have broadened...
-
- : [snip]
- :
- : class Window {
- : public:
- : Window(Style aStyle);
- : enumbit Style { NoTitle, NoBorder, NoResize };
- : };
-
- : create a window with all three window styles set:
-
- : win(Window::NoTitle | Window::NoBorder | Window::NoResize);
- :
- : [snip]
-
- There is a problem with this - namely enum's do not have an operator | ()
- defined on them, so it converts them to an intergral type to perform these
- operations (on my machine the integral type is int).
- So I get this error:
-
- Error: error: bad argument 1 type for Window::Window(): int (Window::Style expected)
-
- With the namespace declaration, your dislike for qualified enums are removed.
-
- using Window::Style;
- ...
- win(NoTitle | NoBorder | NoResize);
-
- This has the advantage of not polluting the global namespace still retains
- type semantics (#defines don't) and can be used without having to
- qualify the enumerated values ;')
-
- Regards
-
- -A.
-
- --
- | A.Champion |
-